﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using Shop.Intermediate;
using DoNet.Common.Utilities;

namespace Shop.Core.Configuration
{
    internal class ConfigAccess
    {
        public static ISysConfiguration Create()
        {
            ISysConfiguration config;
            object o = DataCache.GetCache("config");
            if (o == null)
            {
               config = ConfigurationManager.GetSection("Shop") as ISysConfiguration;
               DataCache.SetCache("config", config);
               return config;
            }
            return o as ISysConfiguration;
        }
        
        public static IDataProvider CreateDataProvider()
        {
            ISysConfiguration config = ConfigAccess.Create();
            return config.DataProvider.GetInstance() as IDataProvider;
        }
    }
}
